package com.mjk.common.ai.service;


import com.mjk.common.ai.entity.KnowledgeBaseQa;
import com.mjk.common.ai.entity.KnowledgeBaseQaRefEmbedding;
import com.mjk.common.core.jdbc.service.plus.idbservice.BeeDBService;
import com.mjk.common.core.jdbc.service.plus.wrap.BeeComplexQueryWrapper;
import com.mjk.common.core.jdbc.service.plus.wrap.BeeQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class KnowledgeBaseQaRecordReferenceService {

    @Autowired
    private BeeDBService beeDBService;

    public List<KnowledgeBaseQaRefEmbedding> listByQaUuid(String aqRecordUuid) {
        BeeComplexQueryWrapper wrapper = new BeeComplexQueryWrapper(KnowledgeBaseQaRefEmbedding.class, "a");
        wrapper.innerJoin(KnowledgeBaseQa.class, "b").on(KnowledgeBaseQaRefEmbedding::getQaRecordId, KnowledgeBaseQa::getId);
        wrapper.eq(KnowledgeBaseQa::getUuid, aqRecordUuid);
        return beeDBService.findManyByWrapper(wrapper);
    }
}
